#include "LocalScene.h"
#include "Utils/LogUtil.h"
#include "LocalEntity.h"
#include "Utils/StringUtil.h"
#include "Game/Component/Model.h"
#include "Render/RenderState.h"
#include "Render/Imgui/imgui.h"
#include "Math/Random.h"


void LocalScene::OnInit()
{

	mCoordinateProcess = GetProcess<CoordinateProcess>("CoordinateProcess");


	GeometryGenerator geometryGenerator;


	GeometryGenerator::MeshData bottomPanelData = geometryGenerator.CreatePanel(5.f, 5.f, glm::vec3(0.f, 1.f, 0.f));

	LocalEntity* bottomPanelEntity = CreateEntity<LocalEntity>("bottomPanel");
	bottomPanelEntity->AddComponent<Model>(bottomPanelData);

	bottomPanelEntity->SetColor(glm::vec4(0.90f, 0.72f, 0.88f, 1.f));

	GeometryGenerator::MeshData sphereData = geometryGenerator.CreateSphere(0.5f, 20, 20);

	LocalEntity* samplerEntity = CreateEntity<LocalEntity>("sampler");
	samplerEntity->AddComponent<Model>(sphereData);
	samplerEntity->GetTransform().SetLocalPosition(glm::vec3(0.f, 3.f, 0.f));
	samplerEntity->GetTransform().UpdateMatrices();

	samplerEntity->SetColor(glm::vec4(0.f, 1.f, 0.f, 1.f));

	LocalEntity* lightEntity = CreateEntity<LocalEntity>("light");
	lightEntity->AddComponent<Model>(sphereData);
	lightEntity->SetColor(glm::vec4(1.f));

	mLightAngle = 0.f;
}

void LocalScene::OnExit()
{

}

void LocalScene::OnTick(float deltaTime)
{
	mLightAngle += deltaTime;

	Entity* lightEntity = GetEntityByName("light");
	lightEntity->GetTransform().SetLocalPosition(glm::vec3(glm::sin(mLightAngle) * 5.f, 5.f, glm::cos(mLightAngle) * 5.f));
	lightEntity->GetTransform().UpdateMatrices();
}

void LocalScene::OnImgui()
{
	GameScene::OnImgui();

#if 1


#endif
}
